package com.csaba.connector.service;

import com.csaba.connector.FlowControlException;

/**
 * Use this FlowControlException when the password is going to / is expired during the login.
 * It can carry additional information about the password type, obligatory or optional change and 
 * remaining days till the password fully expire.
 * <p> Set -1 to day remianing if it is not known / set.
 * <p> Password type constants are defined in the ChangePasswordService.
 *   
 * @author Gabe
 *
 */
public class PasswordExpiredException extends FlowControlException
{
	private static final long serialVersionUID = 128414111949501082L;

	public final static String STAGE_PASSWORD_EXPIRED = "com.csaba.connector.PasswordExpired";
	public final static String PARAM_PASSWORD_TYPE = "com.csaba.connector.fceparam.PasswordType";
	public final static String PARAM_REMAINING_DAYS = "com.csaba.connector.fceparam.RemainingDays";
	public final static String PARAM_OBLIGATORY_CHANGE = "com.csaba.connector.fceparam.ObligatoryChange";

	private final String passwordType;
	private final int remainingDays;
	private final boolean obligarotyChange;

	public PasswordExpiredException( final String passwordType, final int remainingDays, final boolean obligatoryChange )
	{
		super(STAGE_PASSWORD_EXPIRED);

		this.passwordType = passwordType;
		this.remainingDays = remainingDays;
		this.obligarotyChange = obligatoryChange;

		addParameter(PARAM_PASSWORD_TYPE, passwordType);
		addParameter(PARAM_REMAINING_DAYS, remainingDays);
		addParameter(PARAM_OBLIGATORY_CHANGE, obligatoryChange);
	}

	public String getPasswordType()
	{
		return passwordType;
	}

	public int getRemainingDays()
	{
		return remainingDays;
	}

	public boolean isObligarotyChange()
	{
		return obligarotyChange;
	}
}
